//
//  CodeCell.m
//  JiFengDaRen
//
//  Created by Lyc on 2017/11/3.
//  Copyright © 2017年 SH_iOS. All rights reserved.
//

#import "CodeCell.h"
#import "SHQRCodeImageView.h"

@interface CodeCell ()

@property(nonatomic,strong)UIView *bgView;
@property(nonatomic,strong)UIView *topBgView;
@property(nonatomic,strong)UIImageView *weiImgView;
@property(nonatomic,strong)UIImageView *zhiImgView;
@property(nonatomic,strong)UILabel *lable;
@property(nonatomic,strong)SHQRCodeImageView *qrcodeImg;

@end


@implementation CodeCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {

        [self createSubView];
    }
    return self;
}

- (void)createSubView{
    
    _bgView = [[UIView alloc]init];
    _bgView.backgroundColor = [UIColor whiteColor];
    _bgView.layer.cornerRadius = 5;
    [self addSubview:_bgView];
    
    _topBgView = [[UIView alloc]init];
    _topBgView.backgroundColor = [UIColor colorWithHexString:@"#fbfbfb"];
    _topBgView.layer.cornerRadius = 5;
    [_bgView addSubview:_topBgView];
    
//    _weiImgView = [[UIImageView alloc]init];
//    _weiImgView.image = [UIImage imageNamed:@"wei"];
//    [_topBgView addSubview:_weiImgView];
    
    _zhiImgView = [[UIImageView alloc]init];
    _zhiImgView.image = [UIImage imageNamed:@"zhi"];
    [_topBgView addSubview:_zhiImgView];
    
    _lable = [[UILabel alloc]init];
    _lable.text = @"支付宝扫一扫，向我付款";
//    _lable.textColor = KSHTEXTCOLOR;
    _lable.textColor =  [UIColor colorWithHexString:@"#508cee"];
    _lable.textAlignment = NSTextAlignmentCenter;
    _lable.font = KSystemFont(__I6Width(13));
    [_bgView addSubview:_lable];
    
    
    _qrcodeImg = [[SHQRCodeImageView alloc]initWithFrame:CGRectMake(__I6Width(66), __I6Height(69), KScreenWidth - __I6Width(50) - 2 * __I6Width(66), KScreenWidth - __I6Width(50)- 2 * __I6Width(66))];
    _qrcodeImg.qrCodeSmallImage = @"casher_alipay";
//    _qrcodeImg.qrCodeString = [NSString stringWithFormat:@"%@%@%d",BASE_URL,KSWXALIPAYSCANING_PAY,[UserModel shareManager]._id];
    UIImage *qrcodeImage = [_qrcodeImg createNormalSmallImageERImageViewSmallImgSize:CGSizeMake(__I6Width(40), __I6Width(40)) samllImgWhiteBgSize:CGSizeMake(__I6Width(42), __I6Width(42))];
    self.qrcodeImg.image = qrcodeImage;
    [_bgView addSubview:_qrcodeImg];
}

- (void)layoutSubviews{
    
    [_bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top).with.offset(__I6Height(20));
        make.centerX.mas_equalTo(self.mas_centerX);
        make.width.mas_equalTo(KScreenWidth - __I6Width(50));
        make.height.mas_equalTo(KScreenWidth - __I6Width(50));
    }];
    
    [_topBgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(_bgView.mas_top);
        make.left.mas_equalTo(_bgView.mas_left);
        make.width.mas_equalTo(KScreenWidth - __I6Width(50));
        make.height.mas_equalTo(__I6Width(44));
    }];
    
//    [_weiImgView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.mas_equalTo(_topBgView.mas_centerY).mas_offset(__I6Height(1));
//        make.centerX.mas_equalTo(_topBgView.mas_centerX);
//        make.width.mas_equalTo(__I6Height(90));
//        make.height.mas_equalTo(__I6Height(30));
//    }];
    
    [_zhiImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(_topBgView.mas_centerY).mas_offset(__I6Height(1));
        make.centerX.mas_equalTo(_topBgView.mas_centerX);
        make.width.mas_equalTo(__I6Height(70));
        make.height.mas_equalTo(__I6Height(29));
    }];
    
    [_lable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(_bgView.mas_centerX);
        make.bottom.mas_equalTo(_bgView.mas_bottom).mas_offset(__I6Height(-35));
        make.width.mas_equalTo(__I6Width(200));
        make.height.mas_equalTo(__I6Height(13));
    }];
    
    
}
@end
